package test07;

import java.util.Optional;

/**
 *
 * Optional
 *
 * @Author czl
 * @Date 2024-04-12
 */
public class MainTest01 {
    public static void main(String[] args) {
        Student student = new Student("Zs",18);

        String username = Optional
                .of(student)
                .map(Student::getName)
                .map(String::toLowerCase)
                .orElse("匿名");

        System.out.println(username);



        // 拆解
//        Optional<Student> op1 = Optional.of(student) ;
//        Optional<String> op2 = op1.map(Student::getName);
//        Optional<String> op3 = op2.map(String::toLowerCase);
//        String username1 = op3.orElse("匿名");
//
//
//        System.out.println(username1);

    }
}
